package org.delphy.indy2.controls
{
	import flash.events.MouseEvent;
	import flash.filters.BevelFilter;
	import flash.filters.DropShadowFilter;
	import flash.filters.GlowFilter;
	
	import mx.controls.Button;

	public class CarbonButton extends Button
	{
		public var glowFilter:GlowFilter;
		public var shadowFilter:DropShadowFilter;
		public var bevelFilter:BevelFilter;
		
		public function CarbonButton()
		{
			super();
			
			styleName="carbonButton";
			
			glowFilter=new GlowFilter();
			shadowFilter=new DropShadowFilter();
			bevelFilter=new BevelFilter();
			
			addEventListener(MouseEvent.ROLL_OVER,onRollOver);
			addEventListener(MouseEvent.ROLL_OUT,onRollOut);				
		}
		private function onRollOver(evt:MouseEvent):void{
			
			if(!selected)
				filters=[bevelFilter,shadowFilter,glowFilter];
		}
		private function onRollOut(evt:MouseEvent):void{
			filters=[bevelFilter,shadowFilter];
		}	
		
		override protected function commitProperties():void{
			super.commitProperties();
			
			updateFilters();
			filters=[bevelFilter,shadowFilter];			
		}
		
		public function updateFilters():void{
			glowFilter.blurX=getStyle("glowSize");
			glowFilter.blurY=getStyle("glowSize");
			glowFilter.alpha=getStyle("glowAlpha");
			glowFilter.color=getStyle("glowColor");			
			
			bevelFilter.angle=getStyle("bevelAngle");
			bevelFilter.blurX=getStyle("bevelSize");
			bevelFilter.blurY=getStyle("bevelSize");
			bevelFilter.distance=getStyle("bevelDistance");
			bevelFilter.highlightColor=getStyle("bevelHighlightColor");
			bevelFilter.highlightAlpha=getStyle("bevelHighlightAlpha");
			bevelFilter.shadowColor=getStyle("bevelShadowColor");
			bevelFilter.shadowAlpha=getStyle("bevelShadowAlpha");
							
			shadowFilter.blurX=getStyle("shadowSize");
			shadowFilter.blurY=getStyle("shadowSize");
			shadowFilter.distance=getStyle("shadowDistance");
			shadowFilter.angle=getStyle("shadowAngle");
			shadowFilter.alpha=getStyle("shadowAlpha");
			shadowFilter.color=getStyle("shadowColor");
		}
		
	}
}